package com.ymatou.iapi.livebuyer.testcase;

import com.ymatou.iapi.livebuyer.parameter.SendLiveActivityStartMessageBean;
import com.ymatou.iapi.livebuyer.service.SendLiveActivityStartMessageCall;
import com.ymatou.iapi.liveseller.parameter.CreateLiveActivityBean;
import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymatou.iapi.liveseller.parameter.ModifyLiveActivityBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.livevideo.parameter.StreamLiveNotifyBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.GetLog;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
*发送秒杀活动开始通知
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SendLiveActivityStartMessage{
	private static SendLiveActivityStartMessageBean sendliveactivitystartmessageBean;
	private static SendLiveActivityStartMessageCall sendliveactivitystartmessageCall;
	private static int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("发送秒杀活动开始通知");
	}

	@Before
	public void caseUp() {
		sendliveactivitystartmessageBean=new SendLiveActivityStartMessageBean();
		sendliveactivitystartmessageCall=new SendLiveActivityStartMessageCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(sendliveactivitystartmessageCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SendLiveActivityStartMessage_001() {
		Logger.start(true,"发送秒杀活动开始通知成功BizType201");
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			ModifyLiveActivityBean ModifyLiveActivityBean = LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			GetLog getLog=new GetLog("172.16.101.117", "livebuyer.iapi.ymatou.com");
			String reqid=TestDataManager.getRandomUUID().toString().replaceAll("-", "");
			getLog.startListenVm("default.log",reqid);
			sendliveactivitystartmessageBean.setBizType(201);
			sendliveactivitystartmessageBean.setLiveActivityId(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId());
			sendliveactivitystartmessageBean.setLiveId(createlive.getId());
			sendliveactivitystartmessageBean.setRequestId(reqid);
			sendliveactivitystartmessageCall.setData(sendliveactivitystartmessageBean);
			sendliveactivitystartmessageCall.callService();			
			Logger.verifyEquals("ok",sendliveactivitystartmessageCall.getReturnData(),"验证返回");
			Thread.sleep(3000);
			getLog.endListen();
			ArrayList<String> loglist = getLog.getLastLog();
			//验证日志
			loglist.forEach(log->Logger.debug(log));
			List<String> filter = loglist.stream().filter(s->s.contains(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId().toString())).filter(s->s.contains("request body")).collect(Collectors.toList());
			Logger.debug(filter);
			Logger.verifyEquals(1,filter.size(),"验证日志");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendLiveActivityStartMessage_002() {
		Logger.start(true,"发送秒杀活动开始通知成功BizType202");
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			ModifyLiveActivityBean ModifyLiveActivityBean = LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			GetLog getLog=new GetLog("172.16.101.117", "livebuyer.iapi.ymatou.com");
			String reqid=TestDataManager.getRandomUUID().toString().replaceAll("-", "");
			getLog.startListenVm("default.log",reqid);
			sendliveactivitystartmessageBean.setBizType(202);
			sendliveactivitystartmessageBean.setLiveActivityId(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId());
			sendliveactivitystartmessageBean.setLiveId(createlive.getId());
			sendliveactivitystartmessageBean.setRequestId(reqid);
			sendliveactivitystartmessageCall.setData(sendliveactivitystartmessageBean);
			sendliveactivitystartmessageCall.callService();			
			Logger.verifyEquals("ok",sendliveactivitystartmessageCall.getReturnData(),"验证返回");
			Thread.sleep(3000);
			getLog.endListen();
			ArrayList<String> loglist = getLog.getLastLog();
			//验证日志
			loglist.forEach(log->Logger.debug(log));
			List<String> filter = loglist.stream().filter(s->s.contains(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId().toString())).filter(s->s.contains("request body")).collect(Collectors.toList());
			Logger.debug(filter);
			Logger.verifyEquals(1,filter.size(),"验证日志");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendLiveActivityStartMessage_003() {
		Logger.start(true,"直播已结束不发送");
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			ModifyLiveActivityBean ModifyLiveActivityBean = LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			LiveRoomCallService.AutoCloseLiveRoomByUserId(sellerId);
			GetLog getLog=new GetLog("172.16.101.117", "livebuyer.iapi.ymatou.com");
			String reqid=TestDataManager.getRandomUUID().toString().replaceAll("-", "");
			getLog.startListenVm("default.log",reqid);
			sendliveactivitystartmessageBean.setBizType(202);
			sendliveactivitystartmessageBean.setLiveActivityId(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId());
			sendliveactivitystartmessageBean.setLiveId(createlive.getId());
			sendliveactivitystartmessageBean.setRequestId(reqid);
			sendliveactivitystartmessageCall.setData(sendliveactivitystartmessageBean);
			sendliveactivitystartmessageCall.callService();			
			Logger.verifyEquals("ok",sendliveactivitystartmessageCall.getReturnData(),"验证返回");
			Thread.sleep(3000);
			getLog.endListen();
			ArrayList<String> loglist = getLog.getLastLog();
			loglist.forEach(log->Logger.debug(log));
			List<String> filter = loglist.stream().filter(s->s.contains(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId().toString())).filter(s->s.contains("互动直播已关闭或者被删除")).collect(Collectors.toList());
			Logger.debug(filter);
			Logger.verifyEquals(1,filter.size(),"验证日志");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendLiveActivityStartMessage_004() {
		Logger.start(true,"直播已经开始发送");
		//前端会处理展示效果-考虑到延时情况
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 8 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			ModifyLiveActivityBean ModifyLiveActivityBean = LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), sellerId);
			Thread.sleep(10000);
			Logger.debug(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId()+"：秒杀活动开始时间:"+new Date(Long.valueOf(createliveactivityBean.getLiveActivity().getStartTime())));
			GetLog getLog=new GetLog("172.16.101.117", "livebuyer.iapi.ymatou.com");
			String reqid=TestDataManager.getRandomUUID().toString().replaceAll("-", "");
			getLog.startListenVm("default.log",reqid);
			sendliveactivitystartmessageBean.setBizType(202);
			sendliveactivitystartmessageBean.setLiveActivityId(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId());
			sendliveactivitystartmessageBean.setLiveId(createlive.getId());
			sendliveactivitystartmessageBean.setRequestId(reqid);
			sendliveactivitystartmessageCall.setData(sendliveactivitystartmessageBean);
			sendliveactivitystartmessageCall.callService();			
			Logger.verifyEquals("ok",sendliveactivitystartmessageCall.getReturnData(),"验证返回");
			Thread.sleep(3000);
			getLog.endListen();
			ArrayList<String> loglist = getLog.getLastLog();
			//验证日志
			loglist.forEach(log->Logger.debug(log));
			List<String> filter = loglist.stream().filter(s->s.contains(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId().toString())).filter(s->s.contains("202")).collect(Collectors.toList());
			Logger.debug(filter);
			Logger.verifyEquals(true,filter.size()>=1,"验证日志");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendLiveActivityStartMessage_005() {
		Logger.start(true,"直播已经发送通知不发送");
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			ModifyLiveActivityBean ModifyLiveActivityBean = LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			GetLog getLog=new GetLog("172.16.101.117", "livebuyer.iapi.ymatou.com");
			String reqid=TestDataManager.getRandomUUID().toString().replaceAll("-", "");
			getLog.startListenVm("default.log",reqid);
			sendliveactivitystartmessageBean.setBizType(201);
			sendliveactivitystartmessageBean.setLiveActivityId(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId());
			sendliveactivitystartmessageBean.setLiveId(createlive.getId());
			sendliveactivitystartmessageBean.setRequestId(reqid);
			sendliveactivitystartmessageCall.setData(sendliveactivitystartmessageBean);
			sendliveactivitystartmessageCall.callService();			
			Logger.verifyEquals("ok",sendliveactivitystartmessageCall.getReturnData(),"验证返回");
			Thread.sleep(3000);
			getLog.endListen();
			ArrayList<String> loglist = getLog.getLastLog();
			//验证日志
			loglist.forEach(log->Logger.debug(log));
			List<String> filter = loglist.stream().filter(s->s.contains(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId().toString())).filter(s->s.contains("request body")).collect(Collectors.toList());
			Logger.debug(filter);
			Logger.verifyEquals(1,filter.size(),"验证日志");
			
			getLog=new GetLog("172.16.101.117", "livebuyer.iapi.ymatou.com");
			reqid=TestDataManager.getRandomUUID().toString().replaceAll("-", "");
			getLog.startListenVm("default.log",reqid);
			sendliveactivitystartmessageCall.callService();			
			Logger.verifyEquals("ok",sendliveactivitystartmessageCall.getReturnData(),"验证返回");
			Thread.sleep(3000);
			getLog.endListen();
			 loglist = getLog.getLastLog();
			//验证日志
			loglist.forEach(log->Logger.debug(log));
			 filter = loglist.stream().filter(s->s.contains(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId().toString())).filter(s->s.contains("request body")).collect(Collectors.toList());
			Logger.debug(filter);
			Logger.verifyEquals(0,filter.size(),"验证日志");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendLiveActivityStartMessage_006() {
		Logger.start(true,"秒杀活动编号不存在不发送");
		try {
			GetLog getLog=new GetLog("172.16.101.117", "livebuyer.iapi.ymatou.com");
			String reqid=TestDataManager.getRandomUUID().toString().replaceAll("-", "");
			getLog.startListenVm("default.log",reqid);
			sendliveactivitystartmessageBean.setBizType(201);
			sendliveactivitystartmessageBean.setLiveActivityId(-1);
			sendliveactivitystartmessageBean.setLiveId(1);
			sendliveactivitystartmessageBean.setRequestId(reqid);
			sendliveactivitystartmessageCall.setData(sendliveactivitystartmessageBean);
			sendliveactivitystartmessageCall.callService();			
			Logger.verifyEquals("ok",sendliveactivitystartmessageCall.getReturnData(),"验证返回");
			Thread.sleep(3000);
			getLog.endListen();
			ArrayList<String> loglist = getLog.getLastLog();
			//验证日志
			loglist.forEach(log->Logger.debug(log));
			List<String> filter = loglist.stream().filter(s->s.contains("-1")).filter(s->s.contains("互动直播已关闭或者被删除")).collect(Collectors.toList());
			Logger.debug(filter);
			Logger.verifyEquals(1,filter.size(),"验证日志");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendLiveActivityStartMessage_007() {
		Logger.start(true,"秒杀即将开始断流重新推流通知成功BizType201");
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), sellerId);
			StreamLiveNotifyBean notify = LiveRoomCallService.initStreamLiveNotifyBean(createlive.getId(), 0);
			LiveRoomCallService.LiveNotify(notify);
			notify= LiveRoomCallService.initStreamLiveNotifyBean(createlive.getId(), 1);
			//直播即将开始 发送 201
			GetLog getLog=new GetLog("172.16.101.120", "livevideo.ymatou.com");
//			String reqid=TestDataManager.getRandomUUID().toString().replaceAll("-", "");
			getLog.startListenVm("default.log",null);
			
			LiveRoomCallService.LiveNotify(notify);
			ModifyLiveActivityBean ModifyLiveActivityBean = LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
//			
//			sendliveactivitystartmessageBean.setBizType(203);
//			sendliveactivitystartmessageBean.setLiveActivityId(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId());
//			sendliveactivitystartmessageBean.setLiveId(createlive.getId());
//			sendliveactivitystartmessageBean.setRequestId(reqid);
//			sendliveactivitystartmessageCall.setData(sendliveactivitystartmessageBean);
//			sendliveactivitystartmessageCall.callService();			
//			Logger.verifyEquals("ok",sendliveactivitystartmessageCall.getReturnData(),"验证返回");
			Thread.sleep(3000);
			getLog.endListen();
			ArrayList<String> loglist = getLog.getLastLog();
			//验证日志 【系统提示】 画面模糊时，记得手动对焦哦
			loglist.forEach(log->Logger.debug(log));
			List<String> filter = loglist.stream().
					filter(s->s.contains("BizType")).filter(s->s.contains("902")).collect(Collectors.toList());
			Logger.debug(filter);
			Logger.verifyEquals(true,filter.size()>=1,"验证日志");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendLiveActivityStartMessage_008() {
		Logger.start(true,"秒杀开始断流重新推流通知成功BizType203");
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), sellerId);
			StreamLiveNotifyBean notify = LiveRoomCallService.initStreamLiveNotifyBean(createlive.getId(), 0);
			LiveRoomCallService.LiveNotify(notify);
			notify= LiveRoomCallService.initStreamLiveNotifyBean(createlive.getId(), 1);
			Thread.sleep(10000);
			//直播开始 发送 203
			GetLog getLog=new GetLog("172.16.101.120", "livevideo.ymatou.com");
//			String reqid=TestDataManager.getRandomUUID().toString().replaceAll("-", "");
			getLog.startListenVm("default.log",null);
			
			LiveRoomCallService.LiveNotify(notify);
			ModifyLiveActivityBean ModifyLiveActivityBean = LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
//			
//			sendliveactivitystartmessageBean.setBizType(203);
//			sendliveactivitystartmessageBean.setLiveActivityId(ModifyLiveActivityBean.getLiveActivity().getLiveActivityId());
//			sendliveactivitystartmessageBean.setLiveId(createlive.getId());
//			sendliveactivitystartmessageBean.setRequestId(reqid);
//			sendliveactivitystartmessageCall.setData(sendliveactivitystartmessageBean);
//			sendliveactivitystartmessageCall.callService();			
//			Logger.verifyEquals("ok",sendliveactivitystartmessageCall.getReturnData(),"验证返回");
			Thread.sleep(3000);
			getLog.endListen();
			ArrayList<String> loglist = getLog.getLastLog();
			//验证日志 【系统提示】 画面模糊时，记得手动对焦哦
			loglist.forEach(log->Logger.debug(log));
			List<String> filter = loglist.stream().
					filter(s->s.contains("BizType")).filter(s->s.contains("902")).collect(Collectors.toList());
			Logger.debug(filter);
			Logger.verifyEquals(true,filter.size()>=1,"验证日志");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}